import { createRouter, createWebHistory, Router } from 'vue-router'
import Layout from '@/layout/Index.vue'
/**
 * 创建路由数组
 */
const routes: any[] = [
    {
        path: '',
        name: 'index',
        component: Layout,
        redirect: 'index'
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('@/pages/login/Index.vue')
    },
    {
        path: '/index',
        component: Layout,
        name: 'index1',
        children: [
            {
                path: '/index',
                name: 'index2',
                component: () => import('@/pages/index/Index.vue'),
                meta: {
                    title: '首页'
                }
            }
        ]
    },
    {
        path: '/newEnergyScore',
        name: 'newEnergyScore',
        component: () => import('@/pages/newEnergyReportScore/Index.vue')
    },
    //刷新时候报错
    // {
    //     path: '/:pathMatch(.*)',
    //     //访问主页的时候 重定向到index页面
    //     redirect: '/404'
    // },
    // {
    //     path: '/404',
    //     name: '/404',
    //     component: () => import('@/pages/404/index.vue')
    // },

    {
        component: Layout,
        children: [
            {
                path: '/system/menu',
                name: 'menu',
                props: true,
                component: () => import('@/pages/system/menu/list/Index.vue'),
                meta: {
                    title: '菜单编辑',
                    activePath: '/system/menu',
                    hidden: true
                }
            },
            {
                path: '/system/protocol/edit',
                name: 'protocol-edit',
                component: () => import('@/pages/system/protocol/edit/Index.vue'),
                meta: {
                    title: '系统菜单',
                    hidden: true
                }
            },
            {
                path: '/operation/notice/edit',
                name: 'notice:edit',
                component: () => import('@/pages/operation/notice/edit/Index.vue'),
                meta: {
                    title: '新增公告',
                    activePath: '/operation/notice',
                    hidden: true
                }
            },
            {
                path: '/finance/invoice/look',
                name: 'invoice-look',
                component: () => import('@/pages/finance/invoice/look/Index.vue'),
                meta: {
                    title: '开票',
                    activePath: '/finance/invoice',
                    hidden: true
                }
            }
        ]
    }
]

/**
 * 创建History路由
 */
const router: Router = createRouter({
    history: createWebHistory(),
    routes
})

export default router
